package com.tywj.buscustomerapp.view.myview;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class TaylorWebView extends WebView {
    private TaylorWebChromeClient taylorWebChromeClient;
    public TaylorWebView(Context context) {
        super(context);
        initWebView();
    }

    public TaylorWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initWebView();
    }

    public TaylorWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initWebView();
    }



    private void initWebView(){
        taylorWebChromeClient = new TaylorWebChromeClient();
        setWebChromeClient(taylorWebChromeClient);
        WebSettings settings = getSettings();
        settings.setTextZoom(100);
        settings.setUseWideViewPort(true);
        settings.setAllowFileAccess(true);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        settings.setLoadWithOverviewMode(true);
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setGeolocationEnabled(true);
    }

    public void setOnLoginListener(TaylorWebChromeClient.onAlterListener loginListener){
        taylorWebChromeClient.setListener(loginListener);
    }

    public void setOpenFileChooserCallBack(TaylorWebChromeClient.OpenFileChooserCallBack callBack) {
        taylorWebChromeClient.setOpenFileChooserCallBack(callBack);
    }
}
